package math

import (
	"JVM/Jvmgo/GoToJVM/instructions/base"
	"JVM/Jvmgo/GoToJVM/runtimeData"
)

/*
	这里是进行数学 取反 运算
*/

type INEG struct {
	base.NoOperandsInstruction
}
type LNEG struct {
	base.NoOperandsInstruction
}
type FNEG struct {
	base.NoOperandsInstruction
}
type DNEG struct {
	base.NoOperandsInstruction
}

func (self INEG) Execute(frame *runtimeData.Frame) {
	stack := frame.OperandStack()
	val := stack.PopInt()
	stack.PushInt(-val)
}
func (self LNEG) Execute(frame *runtimeData.Frame) {
	stack := frame.OperandStack()
	val := stack.PopLong()
	stack.PushLong(-val)
}
func (self FNEG) Execute(frame *runtimeData.Frame) {
	stack := frame.OperandStack()
	val := stack.PopFloat()
	stack.PushFloat(-val)
}
func (self DNEG) Execute(frame *runtimeData.Frame) {
	stack := frame.OperandStack()
	val := stack.PopDouble()
	stack.PushDouble(-val)
}
